Lesson: 14 - Nested Loops

Purpose : Students learn the concept of nested loops.

Materials Required

Scratch 3.0

Curriculum Content 5.4) Loops

Prior knowledge

Knowledge of looping with repeat and repeat until.

Exercises

Exercise:1



  1. Create a Scratch project that makes the sprite move based on the user’s answers. Sprite asks the user how many steps the sprite should move and how many times it should repeat the movement.

  2. Exercise video:



    See the video for your reference.


    Optional:



    Exercise:2



  3. Write a code to find prime numbers from 2 to 50.You can use the SB3 code done in exercise 3 of Lesson 13 and change it by adding nested loops.

  4. Click here to see the video to know about what is prime?


    Exercise video:



    See the video for your reference.


Solutions



  • Click here to download the sb3 file for exercise-1.

  • Click here to download the sb3 file for exercise-2.


  • Teacher's Instruction
    1. Use the sb3 code done in exercise 1 of Lesson 13 to complete the exercise 1 of Lesson 14.
    2. Emphasise that any control block can be inside any other. i.e. repeat inside another repeat, repeat inside if-then, if-then inside repeat, etc.
    3. Ask the students to think about how many steps this program will take to check if a number is a prime.
    4. Teachers should help to complete the exercise-1 because this exercise will be developed in further lessons.